using SmartLink.EnumLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Code
{
    public sealed class DataAuthorizeRule : AbstractFilterRule
    {
        private static readonly Lazy<DataAuthorizeRule> lazy = new Lazy<DataAuthorizeRule>(() => new DataAuthorizeRule());

        public static DataAuthorizeRule Instance { get { return lazy.Value; } }

        private DataAuthorizeRule() { Initialize(); }

        void Initialize()
        {
            #region 资产管理
            CreateRule(ModuleCodeEnum.VehicleManage, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.VehiclePlateManage, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.StockInOutOrderManage, AuthorizeModeEnum.OID);
            #endregion

            #region 销售管理
            CreateRule(ModuleCodeEnum.CustomerManage, AuthorizeModeEnum.OID_ODID);

            CreateRule(ModuleCodeEnum.CustomerBill, AuthorizeModeEnum.OID_ODID);
            CreateRule(ModuleCodeEnum.GeneratedBill, AuthorizeModeEnum.OID_ODID);

            CreateRule(ModuleCodeEnum.CustomerLibrary, AuthorizeModeEnum.OID_ODID);
            #endregion

            #region 运营管理
            CreateRule(ModuleCodeEnum.IntendedOrder, AuthorizeModeEnum.OID_ODID);
            CreateRule(ModuleCodeEnum.ContractManage, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.ContractTemplate, AuthorizeModeEnum.OID);

            #endregion

            #region 车务管理
            CreateRule(ModuleCodeEnum.ViolationManage, AuthorizeModeEnum.OID);
            #endregion

            #region 财务管理
            CreateRule(ModuleCodeEnum.Receivables, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.Payables, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.FinanceStatements, AuthorizeModeEnum.OID);

            #endregion

            #region 系统设置
            CreateRule(ModuleCodeEnum.ProductType, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.ProductManage, AuthorizeModeEnum.OID);

            CreateRule(ModuleCodeEnum.OrganizationManage, AuthorizeModeEnum.OID);
            CreateRule(ModuleCodeEnum.DepartmentManage, AuthorizeModeEnum.OID);

            CreateRule(ModuleCodeEnum.UserManage, AuthorizationScopeEnum.Root, AuthorizationScopeEnum.Self, AuthorizationScopeEnum.Department, AuthorizationScopeEnum.Organization, AuthorizationScopeEnum.CustomDepartment, AuthorizationScopeEnum.CustomOrganization);
            #endregion
        }
    }
}
